using UnityEngine;

public class CoinsController : CurrencyControllerBase
{
	public bool clickable;

	private int lastCoins;

	private void OnEnable()
	{
		UpdateCurrency(true);
	}

	private void OnDisable()
	{
	}

	public override void UpdateCurrency(bool force = false)
	{
		int coins = GGPlayerSettings.instance.Model.coins;
		if (coins != lastCoins || force)
		{
			label.text = coins.ToString();
		}
		lastCoins = coins;
	}

	public GameObject GetShop()
	{
		if (shop != null)
		{
			return shop.gameObject;
		}
		MainNavigationManager mainNavigationManager = NavigationManager.instance as MainNavigationManager;
		return mainNavigationManager.shop.gameObject;
	}

	public new void OnClick()
	{
		Debug.Log("Click on shop layer");
		if (clickable)
		{
			ShopLayer component = GetShop().GetComponent<ShopLayer>();
			component.ShowTab(ShopLayer.TabEnum.Coins);
			NavigationManager.instance.Push(GetShop());
		}
	}
}
